
import {getCommonSelect} from "@/apilist/public"
import {getAuthList,getModelList} from '@/apilist/Personnel'
const state = {
  //公共数据
    common: {
      positionList: [],
      deptList: [],
      staffList: [],
    },
   auth: {
      list: [],
      model: [],
   },

  model: {
      list: [],
      typeList: [],
  },

  pickerOptions: {
    disabledDate (time) {
      return time.getTime() < Date.now() - 8.64e7
    }
  },

}

 const mutations = {
    getCommonMutation(state,data){
      state.common.positionList = data.position
      state.common.deptList = data.dept
      state.common.staffList = data.staff
    },

    //获取权限
   getAuthListMutations(state,data){
     state.auth.list = data.list
     state.auth.model = data.model
   },

   getModelListMutations(state,data){
      state.model.list = data.list
      state.model.typeList = data.typeList
   }

}

 const actions = {
      async getCommonActions(ctx,data){
        let res = await getCommonSelect(data)
        ctx.commit('getCommonMutation',res.data)
      },
   async getAuthListActions(ctx,data){
     let res = await getAuthList(data)
     ctx.commit('getAuthListMutations',res.data)
   },
   async getModelListActions(ctx,data){
     let res = await getModelList(data)
     ctx.commit('getModelListMutations',res.data)
   }
}


export default {
  namespaced: true,
  state,
  mutations,
  actions
}
